/*
 * Copyright (c) 2012 by Fernando Correa da Conceição
 *
 * This is released under MIT license, read the file LICENSE.txt or
 * http://opensource.org/licenses/mit-license.php .
 */
package info.jaguaribe.jaguaribe;

/**
 * Dialog to rename files/folders
 *
 * @author Fernando Correa da Conceição
 */
public class ToolsRenameDialog extends javax.swing.JDialog {
    /**
     * Hold the current status of dialog.
     *
     * False if the user clicks on Cancel button or close the windows, true if
     * clicks on Ok.
     */
    public boolean status = false;

    /**
     * Creates new form ToolsRenameDialog
     */
    public ToolsRenameDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.buttonChoosePath.setTextField(textPath);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labelPath = new javax.swing.JLabel();
        labelFolder = new javax.swing.JLabel();
        textPath = new javax.swing.JTextField();
        buttonChoosePath = new info.jaguaribe.common.ButtonChooseFile();
        textFolder = new javax.swing.JTextField();
        textFile = new javax.swing.JTextField();
        labelFile = new javax.swing.JLabel();
        labelDescription = new javax.swing.JLabel();
        buttonOk = new javax.swing.JButton();
        buttonCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("info/jaguaribe/jaguaribe/Bundle"); // NOI18N
        labelPath.setText(bundle.getString("ToolsRenameDialog.labelPath.text")); // NOI18N

        labelFolder.setText(bundle.getString("ToolsRenameDialog.labelFolder.text")); // NOI18N

        textPath.setText(bundle.getString("ToolsRenameDialog.textPath.text")); // NOI18N

        buttonChoosePath.setText(bundle.getString("ToolsRenameDialog.buttonChoosePath.text")); // NOI18N

        textFolder.setText(bundle.getString("ToolsRenameDialog.textFolder.text")); // NOI18N

        textFile.setText(bundle.getString("ToolsRenameDialog.textFile.text")); // NOI18N

        labelFile.setText(bundle.getString("ToolsRenameDialog.labelFile.text")); // NOI18N

        labelDescription.setText(bundle.getString("ToolsRenameDialog.labelDescription.text")); // NOI18N

        buttonOk.setText(bundle.getString("ToolsRenameDialog.buttonOk.text")); // NOI18N
        buttonOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonOkActionPerformed(evt);
            }
        });

        buttonCancel.setText(bundle.getString("ToolsRenameDialog.buttonCancel.text")); // NOI18N
        buttonCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCancelActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(labelDescription, javax.swing.GroupLayout.PREFERRED_SIZE, 344, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(labelFile)
                                    .addComponent(labelPath)
                                    .addComponent(labelFolder, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                                    .addComponent(textFile, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(textFolder)
                                    .addComponent(textPath, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(buttonChoosePath, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(76, 76, 76)
                        .addComponent(buttonOk)
                        .addGap(66, 66, 66)
                        .addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(46, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textFile, textFolder, textPath});

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {labelFile, labelFolder, labelPath});

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCancel, buttonOk});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelPath)
                    .addComponent(textPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonChoosePath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelFolder)
                    .addComponent(textFolder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelFile))
                .addGap(18, 18, 18)
                .addComponent(labelDescription, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonOk)
                    .addComponent(buttonCancel))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Event. When the Ok button is clicked.
     *
     * @param evt The event.
     */
    private void buttonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOkActionPerformed
        this.status = true;
        this.dispose();
    }//GEN-LAST:event_buttonOkActionPerformed

    /**
     * Event. When the user clicks on Cancel button.
     *
     * @param evt The event.
     */
    private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
        this.dispose();
    }//GEN-LAST:event_buttonCancelActionPerformed

    /**
     * Get the path choosen in dialog.
     *
     * @return Return the path.
     */
    public String getPath() {
        return textPath.getText();
    }

    /**
     * Get the rules for files
     *
     * @return The rules for files.
     */
    public String getFile() {
        return textFile.getText();
    }

    /**
     * Get the rules for folders.
     *
     * @return The rules for folders.
     */
    public String getFolder() {
        return textFolder.getText();
    }
    //@cond
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonCancel;
    private info.jaguaribe.common.ButtonChooseFile buttonChoosePath;
    private javax.swing.JButton buttonOk;
    private javax.swing.JLabel labelDescription;
    private javax.swing.JLabel labelFile;
    private javax.swing.JLabel labelFolder;
    private javax.swing.JLabel labelPath;
    private javax.swing.JTextField textFile;
    private javax.swing.JTextField textFolder;
    private javax.swing.JTextField textPath;
    // End of variables declaration//GEN-END:variables
    //@endcond
}
